package com.xfly.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.ptmall.app.R;
import com.ptmall.app.utils.GlideUtil;
import com.ptmall.app.utils.TimeUtil;
import com.xfly.app.bean.BankBean;
import com.xfly.app.bean.XsBean;

import java.util.List;


/**
 * Created by Administrator on 2018/1/12.
 */


public class XsAdapter extends BaseAdapter {

    private Context mContext;
    private List<XsBean.ListBean> mDataList;
    private LayoutInflater mLayoutInflater;

    public XsAdapter(Context context, List<XsBean.ListBean> list) {
        this.mContext = context;
        this.mDataList = list;
        this.mLayoutInflater = LayoutInflater.from(mContext);
    }

    public void pushData(List<XsBean.ListBean> list) {
        this.mDataList = list;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        if (mDataList == null) {
            return 0;
        }
        return mDataList.size();
    }

    Click click;

    public void setClick(Click click) {
        this.click = click;
    }


    @Override
    public Object getItem(int position) {
        return mDataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (null == convertView) {
            convertView = mLayoutInflater.inflate(R.layout.item_xs, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        XsBean.ListBean bean = mDataList.get(position);


        switch (bean.getStatus()) {
            case 3:
                viewHolder.status.setText("已到账");
                break;
            default:
                viewHolder.status.setText("未到账");
                break;
        }

        viewHolder.orderno.setText("订单号："+bean.getOrderno()+"");
        viewHolder.orderprice.setText(bean.getPrice()+"");

        viewHolder.time.setText(TimeUtil.getStrTime(bean.getCreate_time()+""));

        return convertView;
    }

    class ViewHolder {

        TextView orderno, orderprice, time, status;

        ViewHolder(View view) {
            orderno = (TextView) view.findViewById(R.id.orderno);
            orderprice = view.findViewById(R.id.orderprice);
            time = view.findViewById(R.id.time);
            status = view.findViewById(R.id.status);
        }
    }

    public interface Click {
        void Click(int position);

        void Click2(int position);
    }

}
